package com.atguigu05._super.ex3;

public class Account {
    private int id;
    private double balance;
    private double annuallnterestRate;
    public Account (int id, double balance, double annuallnterestRate ){
        this.id=id;
        this.balance=balance;
        this.annuallnterestRate=annuallnterestRate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

  //  public void setBalance(double balance) {
   //     this.balance = balance;
   // }

    public double getAnnuallnterestRate() {
        return annuallnterestRate;
    }

    public void setAnnuallnterestRate(double annuallnterestRate) {
        this.annuallnterestRate = annuallnterestRate;
    }
    public double getMonthlylnterest(){
        return this.getAnnuallnterestRate()/12;
    }

    public void withdraw (double amount){
        if(this.balance>=amount){
        this.balance-=amount;
        }
        else{
            System.out.println("余额不足");
        }
    }

    public void deposit (double amount){
        if(amount>0)
        this.balance+=amount;

        System.out.println("余额为:"+balance);
        System.out.println("月利率为："+getMonthlylnterest());
    }

}
